package com.sc.VenusQueryBeta.adapter.home;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sc.VenusQueryBeta.R;
import com.sc.VenusQueryBeta.adapter.BaseCompatAdapter;
import com.sc.VenusQueryBeta.api.Host;
import com.sc.VenusQueryBeta.model.bean.home.HotelPriceBean;

import java.util.List;

/**
 * Created by Administrator on 2018/11/9.
 */

public class PriceAdapter extends BaseCompatAdapter<HotelPriceBean.DataBean, BaseViewHolder> {

    private ImageView imageView;
    private boolean pb = true;
    private TextView room;
    private LinearLayout hotel;

    public PriceAdapter(int layoutResId, @Nullable List<HotelPriceBean.DataBean> data) {
        super(layoutResId, data);
    }

    public PriceAdapter(@Nullable List<HotelPriceBean.DataBean> data) {
        super(data);
    }

    public PriceAdapter(int layoutResId) {
        super(layoutResId);
    }


    @Override
    protected void convert(BaseViewHolder helper, HotelPriceBean.DataBean item) {
        helper.setText(R.id.kaixuan_btn,item.getHotelName());
        room = helper.getView(R.id.kaixuan_btn);
        hotel = helper.getView(R.id.ll_hotel_room);
        if (room != null) {
            room.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (pb) {
                        hotel.setVisibility(View.GONE);
                        pb = false;
                    } else {
                        hotel.setVisibility(View.VISIBLE);
                        pb = true;
                    }
                }
            });
        }
        helper.setText(R.id.type, item.getRoomList().get(0).getRoomDescription());//標間
        helper.setText(R.id.generalPrice, item.getRoomList().get(0).getGeneralPrice());//正常價格
        helper.setText(R.id.specialPrice, item.getRoomList().get(0).getSpecialPrice());//特殊價格
        helper.setText(R.id.remark, item.getRoomList().get(0).getRemark());//注釋
        imageView = helper.getView(R.id.iv_room);
        Glide.with(mContext).load(Host.HostImg + item.getRoomList().get(0).getRoomImageUrl()).diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.drawable.load_error).into(imageView);
    }
}
